package com.fisicaapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class ActPendulo extends Activity {
	private  PenduloView penduloview ;
	private TextView textlong;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.apppendulo);
	    RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_animacionpendulo);
	    textlong =(TextView) findViewById(R.id.p_long_text);	   
	    penduloview = new PenduloView(this);
	    layout.addView(penduloview);	
	    textlong.setText("Longitud : "+ penduloview.longitudlee +"[m]");

	}
	

	public void datos (View view){
		penduloview.pausaAnima();
	
		double [] datos = new double [1];  
		if (penduloview.tipopendulo ==1 )
			datos [0] =1;	
		else
		
			datos [0] =2;
		
 	    Intent i = new Intent(this, ActDatosPendulo.class);
 	    Bundle bundles = new Bundle();
 		bundles.putDoubleArray("arraydatos", datos);
 	    i.putExtras(bundles);
 	    
 	    //startActivityForResult(i, REQUEST_CODE); // no recibire datos devuelta
 	    startActivity(i); 
	}
	public void cpendulo (View view){
		penduloview.pausaAnima();
		if(penduloview.tipopendulo==1){
			penduloview.longitud= 160;	
			penduloview.longitudlee= 0.99;	
			penduloview.tipopendulo=2;
		
			
		}
		else{

			penduloview.longitud= 80;
			penduloview.longitudlee= 0.5;	
			penduloview.tipopendulo=1;
		
			
		}
		  Intent intent = getIntent();
	      finish();
	      startActivity(intent);
	         
		
	}
	public void onBackPressed() {
		penduloview.pausaAnima();
	    finish();

}

}

